<!DOCTYPE html>
<html class="no-js">

<head>
	<meta charset="utf-8">
	<title>问卷调查</title>
	<meta name="description" content="">
	<meta name="HandheldFriendly" content="True">
	<meta name="MobileOptimized" content="320">
	<meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui, user-scalable=no">
	<meta http-equiv="cleartype" content="on">
	<meta name="format-detection" content="telephone=no">

	<link rel="stylesheet" type="text/css" href="/assets/activity/questionnaire/css/common.css?v={BEESCRM:$time}">
	<link rel="stylesheet" type="text/css" href="/assets/activity/questionnaire/css/index.css?v={BEESCRM:$time}">
	<link rel="stylesheet" type="text/css" href="/assets/activity/questionnaire/css/font.css?v={BEESCRM:$time}">
	<link rel="stylesheet" type="text/css" href="/assets/activity/questionnaire/css/swiper.min.css?v={BEESCRM:$time}">
	<link rel="stylesheet" href="/assets/bower_components/sweetalert/lib/sweet-alert.css?v={BEESCRM:$time}">
	<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
</head>
<body>
<div class="wraper">
	<div class="head tb-mode">
		<a href="javascript:history.go(-1);" class="iconfont icon-zuo tb-cell"></a>
		<span class="head-name tb-cell">{BEESCRM:$data.question_title}</span>
		<a href="/base/center/center/account_id/{BEESCRM:$accountId}" class="iconfont icon-geren tb-cell text-right"></a>
	</div>
	<p class="test-tips">{BEESCRM:$data.desc}</p>

	<volist name="data.cate" id="vo">
		<div class="contain-box">
		<div class="cate-title">{BEESCRM:$vo.cate_title}</div>
			<volist name="vo.title" id="vol">
				<div class="test-box <if condition="$key eq 0">show</if>">
					<div class="test-title">{BEESCRM:$vol.title_title}<if condition="$vol.is_multiselect eq 2">(单选)<else/>(多选)</if></div>
					<div class="answer tb-mode clearfix only-title <if condition="$vol.long eq 1">answer-long<else/><if condition="$vol['option_count'] eq 4">forth-answer</if><if condition="$vol['option_count'] eq 3">third-answer</if></if>">
						<volist name="vol.option" id="voli">
							<if condition="$vol.is_multiselect eq 1">
								<div class="tb-cell answer-list single"  onclick='return toggle_multiselect(this);' data-id="{BEESCRM:$data.question_id}*{BEESCRM:$vol.cate_id}*{BEESCRM:$vol.title_id}*{BEESCRM:$voli.option_id}"><div class="option">{BEESCRM:$voli.option_title}</div></div>
								<else/>
							<div class="tb-cell answer-list single" onclick='return toggle(this);' data-id="{BEESCRM:$data.question_id}*{BEESCRM:$vol.cate_id}*{BEESCRM:$vol.title_id}*{BEESCRM:$voli.option_id}"><div class="option">{BEESCRM:$voli.option_title}</div></div>
							</if>
						</volist>
					</div>
				</div>
			</volist>
		</div>
	</volist>
	<div class="contain-box">
		<div class="test-box show"><!--{BEESCRM:$pro_text}-->
			<div class="test-title">其它建议:</div>
			<div class="answer answer-long"><textarea class="textarea" id="pro-text"></textarea></div>
		</div>
	</div>




	<input type="hidden" id="count" value="{BEESCRM:$titlecount}">
	<div class="btn-bottom">
		<a href="javascript:void(0);" class="btn">提交问卷</a>
		<!--未完成测试-->
		<!--<a href="#" class="btn btn-grey">查看结果</a>-->
	</div>
</div>
<include file="share"/>
<script src="/assets/activity/questionnaire/js/jquery-2.1.0.min.js"></script>
<script src="/assets/activity/questionnaire/js/swiper.min.js"></script>
<script src="/assets/activity/questionnaire/js/jq.utils.js"></script>
<script src="/assets/bower_components/sweetalert/lib/sweet-alert.min.js"></script>
<script>
	$(function () {
		var btn_bottom = $('.btn-bottom').outerHeight();
		$('.wraper').css('paddingBottom', btn_bottom+ 8);
	});
	function next(t){
		var $_this = $(".test-box").eq(t);
		$_this.addClass('show');
	}
	function toggle(t){
		if($(t).hasClass('single')){
			$(t).toggleClass('list-check').siblings().removeClass('list-check');
		}
		else if($(t).hasClass('textarea')){

		}
		else{
			$(t).toggleClass('list-check');
		}
		var i = $(".test-box").index($(t).parents(".test-box")) + 1;
		//console.log(i);
		setTimeout(function(){next(i);},100);
	}
	
	function toggle_multiselect(t){
		if($(t).hasClass('single')){
			$(t).toggleClass('list-check');
		}
		else if($(t).hasClass('textarea')){

		}
		else{
			$(t).toggleClass('list-check');
		}
		var i = $(".test-box").index($(t).parents(".test-box")) + 1;
		//console.log(i);
		setTimeout(function(){next(i);},100);
	}
	

	$(document).on('click','.btn',function(){
		var count_check = 0;
		var count_type = true;
		var count = $('#count').val();
		var data = [];k=1;
		$('.list-check').each(function(k,i){
			data.push($(this).data('id'));
		});
		$(".only-title").each(function(k,i){
			 count_check = $(this).children('.list-check').length;
			 if(count_check == 0){
			 	count_type = false;
			 }			 
		});
		
		if(count_type == false){
			$.alert('error','请完成所有题目再提交');
			return false;
		}
		 /*if($.inArray(0,count_check)){
		 	$.alert('error','请完成所有题目再提交');
			return false;
		 }*/
		 /*for (var i=0;i<count_check.length;i++){
			if(count_check[i] == 0){
				$.alert('error','请完成所有题目再提交');
				return false;
			}
		}*/
	/*	if(data.length != count){
			$.alert('error','请完成所有题目再提交');
			return false;
		}*/
		var pro = $('#pro-text').val();
		$.ajax({
			'url':'/activity/questionnaire/doAdd/question_id/{BEESCRM:$questionId}',
			'type':'POST',
			'dataType':'json',
			'data':{info:data,pro:pro},
			'async':false,
			success:function(data){
				if(data.status == 'S'){
					$.alert('success',data.message);
					setTimeout(function(){
						location.href = data.url;
					},2000);
				}else{
					$.alert('error',data.message);
				}
			}
		});
	});
</script>
</body>
</html>
